#! /usr/bin/env python

# -*- coding: UTF-8 -*-
# ==============================================================================
# Filename : Preferences.py
# Purpose  : 
# Author   : Yohann Li (lyh001686@sina.com)
# Date     : 2020-08-28 11:25
# ==============================================================================
import sys

from PyQt5.QtGui import QKeySequence, QFont
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, \
    QShortcut


class Preferences(QWidget):
    def __init__(self):
        super(Preferences, self).__init__()
        self.setWindowModality(Qt.ApplicationModal)
        self.set_shortcut()
        self.app_ = QApplication.instance()
        self.resize(int(QApplication.desktop().screen().width()*0.6), int(QApplication.desktop().screen().height()*0.6))
        self.setWindowTitle('Preferences')
        # self.set_ui()

    def set_shortcut(self):
        QShortcut(QKeySequence.Close, self).activated.connect(self.close)

    # def set_ui(self):
    #     self.cb = QFontComboBox(self)
    #     self.cb.currentFontChanged.connect(self.test)
    #     lab = QLabel('from configuration import logger', self)
    #     grid_ = QGridLayout(self)
    #     grid_.addWidget(lab, 0, 1)
    #     grid_.addWidget(self.cb, 1, 1)

    def test(self, font: QFont):
        QApplication.setFont(font)
        # self.setFont(font)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    p = Preferences()
    p.show()
    sys.exit(app.exec_())
